package EvaTCPL;
import java.lang.Math;

public class EvaTCPLsgn extends EvaTCPLaexpression
{

  public EvaTCPLsgn(EvaTCPLaexpression e)
    {
      super(e);
    }

  /** Evaluate this arithmetic expression. */
  public double evaluate()
    { 
      double val = sons[0].evaluate();

      if (val<0) {
	return -1;
      }
      else if (val==0) {
	return 0;
      }
      else {
	return 1;
      }
    }

  public String toString()
    {
      return "sgn("+sons[0].toString()+")";
    }

}
